<template>
	<view :style="[{paddingTop:CustomBar+'px'}]">
		<cu-custom bgColor="bg-white" :isBack="true" fatherCss="box-shadow:none">
			<block slot="backText"></block>
			<block slot="content">我的折扣卡</block>
		</cu-custom>
		<view class="particulars-cont" :style="[{minHeight: scrollH-CustomBar-10+'px'}]">
			<view class="detail-list">
				<view class="item" v-for="(item,index) in voucherList" :key="index">
					<view class="orange" :class="item.status == 2 || item.status == 3?'active':''">
						<view>商城<text></text></view>
						<view>特权卡</view>
					</view>
					<view class="info">
						<view class="">
							<view class="">
								云商城商品特权卡
							</view>
							<view class="">{{item.create_time}}</view>
						</view>
						<view class="price">
							<view class="" v-if="item.status == 1" @click="goShopping">
								去使用
							</view>
							<image src="https://xarkbucket.oss-cn-hangzhou.aliyuncs.com/has-used.png" mode="" v-if="item.status == 2"></image>
							<image src="https://xarkbucket.oss-cn-hangzhou.aliyuncs.com/past-due.png" mode="" v-if="item.status == 3"></image>
						</view>
					</view>
				</view>
				<no-content :showType="'card2'" v-if='noContent'></no-content>
				<tui-divider width="60%" :gradual="true" v-if="noMore">没有更多了~</tui-divider>
			</view>
		</view>
	</view>
</template>

<script>
	import noContent from './component/noContent'
	export default {
		components: {
			noContent
		},
		data() {
			return {
				CustomBar: this.CustomBar,
				scrollH: '',
				page: 1,
				lastPage: '',
				voucherList: [],
				noContent: false,
				noMore: false
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#000000',
				backgroundColor: '#ffffff'
			})
		},
		onLoad(options) {
			uni.getSystemInfo({
				success: (res) => {
					this.scrollH = res.windowHeight
				}
			})

			this.getList()
		},
		methods: {
			goShopping(){
				// uni.showModal({
				// 	title:'温馨提示',
				// 	content:'暂未开启商城，敬请期待！',
				// 	showCancel: false
				// })
				uni.switchTab({
					url:'/pages/tabBar/cloudMall'
				})
			},
			getList() {
				var that = this
				this.$request({
					url: '/ShopPrerogative/get_user_ticket',
					data: {
						page: that.page
					},
					success: res => {
						if (res.data.status == 1) {
							if (res.data.data.totalNum == 0) {
								that.noContent = true
								return
							}
							if(that.page==1&&res.data.data.pageCount == 1){
								that.noMore = true
							}
							that.voucherList = that.voucherList.concat(res.data.data.data)
							that.page++
							that.lastPage = res.data.data.pageCount
						}
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				});
			},

			changeTruth(index) {
				this.truthIndex = index
			}
		},
		onReachBottom() {
			if (this.page > this.lastPage) {
				this.noMore = true
				return
			}
			this.getList()
		}
	}
</script>

<style>
	page {
		background: #f5f5f5;
	}
</style>
<style scoped>
	.particulars-cont {
		width: 100%;
		background: #f5f5f5;
		margin: 0 auto;
		display: flex;
		flex-direction: column;
	}

	.top-truth {
		height: 80rpx;
		width: 100%;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		background-color: #ffffff;
		display: flex;
	}

	.top-truth>view {
		flex: 1;
		border-bottom: 4rpx solid transparent;
		box-sizing: border-box;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		font-size: 30rpx;
		color: #333333;
	}

	.top-truth .active {
		border-bottom: 4rpx solid #f34930;
		color: #f34930;
	}

	.detail-list {
		flex: 1;
		padding: 30rpx 24rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		overflow-y: auto;
	}

	.detail-list .item {
		display: flex;
		border-radius: 8rpx;
		margin-bottom: 30rpx;
	}

	.detail-list .item .orange {
		width: 160rpx;
		height: 160rpx;
		border-radius: 8rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		background-color: #f8990b;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
		box-sizing: border-box;
	}

	.detail-list .item .orange.active {
		background: #adadad !important;
	}


	.detail-list .item .orange view {
		color: #fff;
		font-size: 30rpx;
	}

	.detail-list .item .orange view text {
		font-size: 40rpx;
		font-weight: bold;
	}

	.detail-list .item .info {
		flex: 1;
		display: flex;
		justify-content: space-between;
		border-radius: 8rpx;
		background: #fff;
	}

	.detail-list .item .info>view:nth-child(1) {
		flex: 1;
		display: flex;
		flex-direction: column;
		padding: 20rpx;
		justify-content: space-between;
	}

	.detail-list .item .info>view:nth-child(1)>view:nth-child(1) {
		font-size: 28rpx;
		letter-spacing: 1rpx;
		color: #333333;
	}

	.detail-list .item .info>view:nth-child(1)>view:nth-child(2) {
		font-size: 26rpx;
		letter-spacing: 1rpx;
		color: #999999;
	}

	.detail-list .item .info>view:nth-child(2) {
		width: 160rpx;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.detail-list .item .info>view:nth-child(2) view {
		font-size: 28rpx;
		line-height: 48rpx;
		letter-spacing: 1rpx;
		color: #f34930;
		width: 120rpx;
		height: 48rpx;
		background-color: #ffffff;
		border-radius: 24rpx;
		border: solid 1rpx #f34930;
		text-align: center;
	}

	.detail-list .item .info>view:nth-child(2) image {
		width: 88rpx;
		height: 88rpx;
	}
</style>
